<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


 <style>
	#cacheDiv {
	font-size:14px;
  width: 100%; height: 100%;
  border: 0; padding: 5; margin: 0;
}
	
	</style>
</head>
<body class="nihilo">

 <div  style="width:300px;height:300px;float:right">
	<div dojoType="dijit.TitlePane" open="false" title="功能说明">
		<p>
		Memcached 内存对象缓存系统配置管理。
		</p>
	  
	</div>
	<div dojoType="dijit.TitlePane" open="false" title="如何使用">
		<p>
举例：
<br><br>

<?
	$p = <<<EOT
<?php  
$ GLOBALS["gMemcacheServer"]["192.168.1.5:11213"] = 
array (
  'mmhost' => '192.168.1.5',
  'mmport' => '11213',
); 
?>
EOT;
 highlight_string($p);

?>
	<br><br>
	</p>
		</div>
</div>
	
	<div style="margin:10px;">位置: 缓存管理  > Memcached设置</div>
	<div style="margin:10px;">
		<button dojoType="dijit.form.Button" onclick="dijit.byId('newMemcached').show();">新建Memcached</button>
	</div>
	
	<table style="width:600px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:450px;background-color:#eee">Memcached</td>
		
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">操作</td>
		</tr>
		</thead>
		<tbody id="memcachedlist">
		<?php foreach($memcached as $item){?>
		<tr id="memcached_<?=$item['host']?>">
		<td><a href="javascript:view_memcached('<?=$item['host']?>');" ><?=$item['host']?></a></td>
		<td><button dojoType="dijit.form.Button" onclick="editMemcached('memcached_<?=$item['host']?>','<?=$item['host']?>');">修改</button><button dojoType="dijit.form.Button" onclick="deleteMemcached('memcached_<?=$item['host']?>','<?=$item['host']?>');">删除</button></td>
		</tr>
		<? }?>
		</tbody>
	</table>
	
		

	



<div dojoType="dijit.Dialog" id="newMemcached" title="新建Memcached" >
	<div style="margin:5px;">
			<button dojoType="dijit.form.Button" onclick="addRow('memcached_table');">新增参数</button>
	</div>
	<div method="" jsid="memcached_form" id="memcached_form" dojoType="dijit.form.Form" action="">
		<script type="dojo/method" event="onSubmit">
		 if (this.validate()) {
            var xhrArgs = {
					url:gSiteUrl+"/index.php",
        	        form: "memcached_form",
        	        handleAs: "json",
        	        load: function(data){
    	    
						if(data.s==200){
	            			//新增行
			            	var rowid= "memcached_"+data.d;
			            	var host = data.d;
			            	
			            	var row=document.createElement("tr");   
			            	row.id= rowid; 
		
			            	var td = document.createElement("td");
			            	var aNode = dojo.create("a", { href: "javascript:view_memcached('"+host+"');", title: "view host!", innerHTML: host }); 
			            	td.appendChild(aNode);
			            	row.appendChild(td);
			            	
			            	var td = document.createElement("td");
			            	var editbtn =new dijit.form.Button({label:"修改",onClick:function(){editMemcached(rowid,host)}});
			            	var deletebtn =new dijit.form.Button({label:"删除",onClick:function(){deleteMemcached(rowid,host)}});
			            	td.appendChild(editbtn.domNode);
			            	td.appendChild(deletebtn.domNode);
			            	row.appendChild(td);		            	
			            	dojo.byId('memcachedlist').appendChild(row);
	
			            	//表单重置
		        	      	dojo.byId('memcached_form').reset();
	
		        	      	  
		            	    dijit.byId('newMemcached').hide();
		        	        dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
						}
						if(data.s==400){
    	        			dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
        	        },
        	        error: function(error,ioargs){
            	      var message = httpErrorReport(ioargs.xhr.status);
        	          dojo.byId("AlertCon2").innerHTML = message;
        	          dijit.byId("AlertShow2").show();
        	        }
        	      }
         
          	var deferred = dojo.xhrPost(xhrArgs);
        	
            return false;
        } else {
           
            return false;
        }
		</script>
		
		<input type="hidden" name="action" value="cache">
		<input type="hidden" name="op" value="savememcached">
		<table style="width:500px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">变量</td>
		<td style="border-bottom:1px solid #ccc;width:250px;background-color:#eee">值</td>
		<td style="border-bottom:1px solid #ccc;width:100px;background-color:#eee">备注</td>
		</tr>
		</thead>
		<tbody id="memcached_table">
	
		<tr id="row_mmhost">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_mmhost" value="mmhost" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp="[0-9\.]+" invalidMessage="变量名不符合规则:[0-9\.]+" type="text" name="valu_mmhost" id="valu_mmhost" value=""></td>
		<td><label>主机地址</label></td>
		</tr>
		<tr id="row_mmport">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_mmport" value="mmport" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" type="text" name="valu_mmport" id="valu_mmport" value="" regExp="[0-9]+" invalidMessage="变量名不符合规则:[0-9]+"></td>
		<td><label>端口</label></td>
		</tr>
	
		</tbody>
		<tfoot>
		<tr>
		     <td colspan="2" align="center">
		       <button dojoType="dijit.form.Button" type="submit">保存</button>
		       <button dojoType="dijit.form.Button" type="reset">重置</button>
		       </td>
		   </tr>
		 </tfoot>	
		</table>
	</div>
</div>



<div dojoType="dijit.Dialog" id="editMemcached" title="修改Memcached" >
	<div style="margin:5px;">
			<button dojoType="dijit.form.Button" onclick="addRow('memcached_edit_table');">新增参数</button>
	</div>
	<div method="" jsid="memcached_edit_form" id="memcached_edit_form" dojoType="dijit.form.Form" action="">
		<script type="dojo/method" event="onSubmit">
		if (this.validate()) {
            var xhrArgs = {
					url:gSiteUrl+"/index.php",
        	        form: dojo.byId('memcached_edit_form'),
        	        handleAs: "json",
        	        load: function(data){
    	        		if(data.s==200){
	    	        		//alert(data);
							//删除旧行
							var old_memcached = dojo.byId("edit_host").value;
							//alert(old_memcached);
	            			dojo.byId("memcachedlist").removeChild(dojo.byId("memcached_"+old_memcached));
	    	        		
			            	//新增行
			            	var rowid= "memcached_"+data.d;
			            	
			            	var host = data.d;
			            	
			            	var row=document.createElement("tr");   
			            	row.id= rowid; 
			
			            	var td = document.createElement("td");
			            	var aNode = dojo.create("a", { href: "javascript:view_memcached('"+host+"');", title: "view host!", innerHTML: host }); 
			            	td.appendChild(aNode);
			            	
			            	row.appendChild(td);
			            	
			            	var td = document.createElement("td");
			            	var editbtn =new dijit.form.Button({label:"修改",onClick:function(){editMemcached(rowid,host)}});
			            	var deletebtn =new dijit.form.Button({label:"删除",onClick:function(){deleteMemcached(rowid,host)}});
			            	td.appendChild(editbtn.domNode);
			            	td.appendChild(deletebtn.domNode);
			            	row.appendChild(td);		            	
			            	dojo.byId('memcachedlist').appendChild(row);
			            	
			            	//表单重置
		        	      	//dojo.byId('memcached_edit_form').reset();
	 	      	  
		            	    dijit.byId('editMemcached').hide();
		        	        dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
    	        		if(data.s==400){
    	        			dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
        	        },
        	        error: function(error,ioargs){
            	      var message = httpErrorReport(ioargs.xhr.status);
        	          dojo.byId("AlertCon2").innerHTML = message;
        	          dijit.byId("AlertShow2").show();
        	        }
        	      }
         
          	var deferred = dojo.xhrPost(xhrArgs);
        	
            return false;
        } else {
            
            return false;
        }
		</script>
		
		<input type="hidden" name="action" value="cache">
		<input type="hidden" name="op" value="updatememcached">
		<input type="hidden" name="edit_host" id="edit_host" value="">
		
		<table style="width:500px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">变量</td>
		<td style="border-bottom:1px solid #ccc;width:250px;background-color:#eee">值</td>
		<td style="border-bottom:1px solid #ccc;width:100px;background-color:#eee">操作</td>
		</tr>
		</thead>
		<tbody id="memcached_edit_table">
		
		</tbody>
		<tfoot>
		<tr>
		     <td colspan="2" align="center">
		       <button dojoType="dijit.form.Button" type="submit">保存</button>
		       <button dojoType="dijit.form.Button" type="reset">重置</button>
		       </td>
		   </tr>
		 </tfoot>	
		</table>
	</div>
</div>





</body>
</html>